import { expect } from 'chai';
import stringifyQuery from '../src/stringifyQuery';

describe('stringifyQuery unit test', function() {
    it('should return empty string if missing arguments', function() {
        expect(stringifyQuery()).to.be.eql('');
    });

    it('should print valid string for single obj', function() {
        expect(stringifyQuery({ answer: 42 })).to.be.eql('answer=42');
    });

    it('should ignore undefined variables', function() {
        expect(stringifyQuery({ answer: 42, age: undefined })).to.be.eql('answer=42');
    });

    it('should print valid string for two obj', function() {
        const params = {
            foo: 'bar',
            age: 42,
        };
        expect(stringifyQuery(params)).to.be.eql('foo=bar&age=42');
    });

    it('should print valid string for encoded params', function() {
        expect(stringifyQuery({ foo:'?' }, true)).to.be.eql('foo=%3F');
    });
});